﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LunarSF.SHomeWorkshop.LunarMarkdownEditor.GraphicDemonstrator
{
    public class DemoResourceInfo
    {
        public string LinkTitle { get; set; }

        public string LinkType { get; set; }

        public string RelativePath { get; set; }

        public string AbsolutePath
        {
            get
            {
                if (string.IsNullOrWhiteSpace(RelativePath))
                {
                    if (Globals.MainWindow.tvWorkDirectory.Items.Count <= 0) return "";

                    var rootWtvi = Globals.MainWindow.tvWorkDirectory.Items[0] as WorkspaceTreeViewItem;
                    if (rootWtvi == null) return "";

                    return rootWtvi.MetaHtmlFilePath;
                }

                return Globals.PathOfWorkspace.TrimEnd('\\') + "\\" + RelativePath.TrimStart('\\');
            }
        }
    }
}
